home *** CD-ROM | disk | FTP | other *** search
- <?php
- ////////////////////////////////////////////////////////////////////////////////
- // <!--Copyright (c) 2006 Pure Networks Inc. All rights reserved.-->
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Build: 3.0.6121.0 (Stable)
- // $Revision: #1 $
- //
-
- $sNavLocation = "webcamera";
- $sNavPage = "webcamera";
- $sLocation = "Web Camera";
- require '_session_common.php';
-
- if (!$bLoggedIn && $bWebCameraIsPrivate)
- {
- ///////////////////////////////////////////////////
- // Webcamera is private and user is not logged in, go away.
- ///////////////////////////////////////////////////
- log_activity("private folder request without session", "error", return_error_text(308, "", $arErrors));
- gotoAbs('/login/308');
- exit();
- }
-
- $bUnknownCameraType = false;
- $bIncompatibleBrowser = false;
- $sCamIPLastTwoOctets = "";
- $iErrorCode = 0;
- $sCameraGuid = $_GET['Guid'];
- if (isValidString($sCameraGuid)) { $sCameraGuid=str_replace("\\\\", "\\", $sCameraGuid);} else { $sCameraGuid = ""; }
- $bValidCameraPassedViaGet = false;
- $sCamIPAddress = "";
- $sCamFriendlyName = "";
- $sCamVendorName = "";
- $sCamModelDescription = "";
- $sCamModelName = "";
- $sCamModelNumber = "";
- $sCamIPLastTwoOctets = "";
- $fCameraUSB = false;
- $fCameraOnline = false;
- $objCamera = null;
-
- ///////////////////////////////////////////////////
- // let's get the cameras
- ///////////////////////////////////////////////////
- try
- {
- if ($bAutoDetectWebCams && $bAutoDetectUSBCams)
- {
- $nmUSBCameras = $nmNetworkLib->USBCameras;
- if (count($nmUSBCameras) > 0)
- {
- foreach ($nmUSBCameras as $camera)
- {
- $nmCameras[] = $camera;
- }
- }
-
- $nmWebCameras = $nmNetworkLib->WebCameras;
- if (count($nmWebCameras) > 0)
- {
- foreach ($nmWebCameras as $camera)
- {
- $nmCameras[] = $camera;
- }
- }
- }
- else if ($bAutoDetectWebCams)
- {
- $nmCameras = $nmNetworkLib->WebCameras;
- }
- else if ($bAutoDetectUSBCams)
- {
- $nmCameras = $nmNetworkLib->USBCameras;
- }
- }
- catch(Exception $ex)
- {
- $nmCameras = null;
- log_activity("Attempting nmNetworkLib->WebCameras", "exception", $ex->getMessage() . " (" . $ex->getCode() . ")");
- }
- if (count($nmCameras) > 0)
- {
- foreach ($nmCameras as $camera)
- {
- try
- {
- if ($camera->Guid == $sCameraGuid)
- {
- $objCamera = $camera;
- $fCameraUSB = $camera->USB;
- if (!$fCameraUSB)
- {
- $rIPAddressSplit = explode(".",$camera->IPAddress);
- $sCamIPLastTwoOctets = $rIPAddressSplit[2] . "." . $rIPAddressSplit[3];
- $sCamIPAddress = $camera->IPAddress;
- }
- $sCamFriendlyName = $camera->FriendlyName;
- $sCamVendorName = $camera->VendorName;
- $sCamModelDescription = $camera->ModelDescription;
- $sCamModelName = $camera->ModelName;
- $sCamModelNumber = $camera->ModelNumber;
- $fCameraOnline = $camera->Online;
- $bValidCameraPassedViaGet = true;
- }
- }
- catch(Exception $ex)
- {
- // in case any of above aren't implemented, etc...
- log_activity("Trying to find which camera we are dealing with", "exception", $ex->getMessage() . " (" . $ex->getCode() . ")");
- }
- }
- }
-
- // if bValidCameraPassedViaGet is still false, we have some manipulation of GET params going on (OR bad camera...)
- if (!$bValidCameraPassedViaGet)
- {
- log_activity("Webcamera guid not found: " . $sCameraGuid, "failure", return_error_text(510, "", $arErrors));
- gotoAbs('/error/510');
- exit();
- }
-
- if (!$fCameraOnline)
- {
- $iErrorCode = 513;
- }
-
- try
- {
- $sLanIp = "http://" . $nmRaManager->LanIP;
- $sWanIp = $nmRaManager->HomeUrl;
-
- // We have the DNS URL, let's get the home. version of it to use in the direct URLs...
- $iStartUrl = strpos($sWanIp, "://") + 3;
- $sUrl = substr($sWanIp, $iStartUrl);
- $iEndSubDomain = strpos($sUrl, ".");
- $sSubDomain = substr($sUrl, 0, $iEndSubDomain);
- $sWanIp = str_replace($sSubDomain, $sSubDomain . "." . $sWaHomeSubDomain, $sWanIp);
-
- // see if they are accessing the site as a private address and respond accordingly
- $sServerIpPort = $_SERVER['HTTP_HOST'];
- $iServerPortPos = strpos($sServerIpPort, ":");
- $sServerIP = substr($sServerIpPort, 0, $iServerPortPos);
- if (isIpAddressPrivate($sServerIP))
- {
- $sIpToUse = $sLanIp;
- }
- else
- {
- $sIpToUse = $sWanIp;
- }
-
- $sIpToUse .= ":8008"; // TODO: remote port
-
- // only partial octets to avoid open redirector
- $sIpToUse .= "/internal/redir/" . $sCamIPLastTwoOctets . "/";
- }
-
- catch (exception $ex)
- {
- log_activity("Attempting nmRaManager->HomeUrl", "exception", $ex->getMessage() . " (" . $ex->getCode() . ")");
- $iErrorCode = 513;
- }
-
- ///////////////////////////////////////////////////
- // start printing out the HTML to the browser
- ///////////////////////////////////////////////////
- require "_header.php";
- require "_cookie_util.php";
-
- try
- {
- $sDebug = $_GET['Debug'];
- if ("true" == $sDebug)
- {
- echo ("<br>Vendor: " . $sCamVendorName);
- echo ("<br>ModelName: " . $sCamModelName);
- echo ("<br>ModelNumber: " . $sCamModelNumber);
- echo ("<br>ModelDescription: " . $sCamModelDescription);
- echo ("<br>IPAddress: " . $sCamIPAddress);
- echo ("<br>Guid: " . $sCameraGuid);
- echo ("<br>IsUSB: " . $fCameraUSB);
- echo ("<br>IpToUse:" . $sIpToUse);
- }
- }
- catch (exception $ex)
- {
- log_activity("Enumerating camera debug details", "exception", $ex->getMessage() . " (" . $ex->getCode() . ")");
- }
-
- ?>
-
-
- <table cellspacing="0" cellpadding="0" border="0" width="100%">
- <tr>
- <td width="100%" valign="top">
- <?php require "_public_error_states.php"; ?>
- <!-- Start Folder view table -->
- <table cellspacing="0" cellpadding="0" border="0" class="ContentTable">
- <tr>
- <td class="ContentTableTL"><div> </div></td>
- <td class="ContentTableTM2"><div><strong><?php echo(HtmlSpecialChars($sCamFriendlyName)); if ($fCameraUSB) { echo (" USB Camera" ); } else { echo (" Web Camera"); } ?></strong></div></td>
- <td class="ContentTableTM3"> </td>
- <td class="ContentTableTR"><div> </div></td>
- </tr>
- <tr>
- <td class="ContentTableML"><div> </div></td>
- <td class="ContentTableMM" colspan="2">
- <div class="ShareContents" style="text-align:center;">
- <br/>
-
- <?php
-
- if ($iErrorCode == 0)
- {
- require "cameras/webcamerautils.php";
- staticImageStyleWriteOut("640", "480");
-
- // Figure out what vendor's camera.php to include
- if ($fCameraUSB)
- {
- require "cameras/USB.php";
- }
- else if (strpos(strtolower($sCamVendorName),"d-link") !== false)
- {
- require "cameras/D-Link.php";
- }
- else if (strpos(strtolower($sCamVendorName),"trendnet") !== false)
- {
- require "cameras/TRENDnet.php";
- }
- else if (strpos(strtolower($sCamVendorName),"cellvision") !== false)
- {
- require "cameras/TRENDnet.php"; // purposefully use trendnet for cellvision
- }
- else if (strpos(strtolower($sCamVendorName),"linksys") !== false)
- {
- require "cameras/Linksys.php";
- }
- else if (strpos(strtolower($sCamVendorName),"veo") !== false)
- {
- require "cameras/Veo.php";
- }
- else
- {
- $iErrorCode = 511;
- }
- }
-
- if ($iErrorCode != 0)
- {
- ?>
- <table cellpadding="0" cellspacing="0" border="0">
- <tr><td class="SucceedTableTop"><div> </div></td></tr>
- <tr>
- <td class="SucceedTableMid" style="text-align:left;">
- <div class="EmptyContianerImage">
- <div class="EmptyContianerText">
- An error occurred
- </div>
- <div class="EmptyContianerExplain">
- <?php echo return_error_text($iErrorCode, "", $arErrors);?>
- </div>
- </div>
- </td>
- </tr>
- <tr><td class="SucceedTableBot"><img src="/images/pixel.trans.gif" width="1" height="1" alt=""/></td></tr>
- </table>
- <?php
-
- }
- ?>
- </div> <!--ShareContents-->
- </td>
- <td class="ContentTableMR"> </td>
- </tr>
- <tr>
- <td class="ContentTableBL"> </td>
- <td class="ContentTableBM" colspan="2"> </td>
- <td class="ContentTableBR"> </td>
- </tr>
- </table> <!-- End Folder View Table -->
- </td>
- <td valign="top">
- <?php
- ///////////////////////////////////////////////////
- // Define the tasks for this page
- ///////////////////////////////////////////////////
- $iTaskCount = 0;
-
- require "_network_map.php";
- require "_tasks_panel.php";
- ?>
- </td>
- </tr>
- </table>
- <?php
- ///////////////////////////////////////////////////
- // Finish printing out the HTML to the browser
- ///////////////////////////////////////////////////
- require "_footer.php";
- ?>
-